home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Text Capture FKEY / Text Capture source.cpt / Configure_dialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-17  |  3.0 KB  |  103 lines  |  [TEXT/KAHL]

  1. #include "defs.h"
  2. #include "Prefs.h"
  3. #include "embedded resources.h"
  4.  
  5. enum {    // enabled DITL items
  6.     i_OK = 1,
  7.     i_cancel,
  8.     i_return,
  9.     i_space,
  10.     i_window,
  11.     i_everywhere,
  12.     i_selected_rect,
  13.     i_fake_activate
  14. };
  15.  
  16. void Configure_dialog( void )
  17. {
  18.     ControlHandle    return_h, space_h, window_h, everywhere_h, selected_h;
  19.     ControlHandle    fake_activate_h;
  20.     DialogPtr        dp;
  21.     Rect            box;
  22.     short            itype;
  23.     Boolean            spaces_temp;
  24.     char            copy_mode_temp;
  25.     Boolean            fake_activate_temp;
  26.     short            item_hit;
  27.     GrafPtr            save_port;
  28.     short            save_resfile;
  29.     
  30.     GetPort( &save_port );
  31.     save_resfile = CurResFile();
  32.     UseResFile( pref_resfile );
  33.     
  34.     dp = GetNewDialog( DLOG_ID, NIL, (WindowPtr)-1L );
  35.     if (dp != NIL)
  36.     {
  37.         /* Get handles to the radio buttons. */
  38.         GetDItem( dp, i_return, &itype, (Handle *)&return_h, &box );
  39.         GetDItem( dp, i_space, &itype, (Handle *)&space_h, &box );
  40.         GetDItem( dp, i_window, &itype, (Handle *)&window_h, &box );
  41.         GetDItem( dp, i_everywhere, &itype, (Handle *)&everywhere_h, &box );
  42.         GetDItem( dp, i_selected_rect, &itype, (Handle *)&selected_h, &box );
  43.         GetDItem( dp, i_fake_activate, &itype, (Handle *)&fake_activate_h, &box );
  44.         
  45.         /* Initialize the values of the radio buttons. */
  46.         spaces_temp = spaces;
  47.         copy_mode_temp = copy_mode;
  48.         fake_activate_temp = fake_activate;
  49.         SetCtlValue( return_h, !spaces_temp );
  50.         SetCtlValue( space_h, spaces_temp );
  51.         SetCtlValue( window_h, copy_mode_temp == c_window );
  52.         SetCtlValue( everywhere_h, copy_mode_temp == c_all );
  53.         SetCtlValue( selected_h, copy_mode_temp == c_selected );
  54.         SetCtlValue( fake_activate_h, fake_activate );
  55.         
  56.         /* Show the window and go... */
  57.         ShowWindow( dp );
  58.         SetPort( dp );
  59.         do {
  60.             ModalDialog( NIL, &item_hit );
  61.             if ( ((item_hit == i_return) && spaces_temp)
  62.                 || ((item_hit == i_space) && !spaces_temp) )
  63.             {
  64.                 spaces_temp = !spaces_temp;
  65.                 SetCtlValue( return_h, !spaces_temp );
  66.                 SetCtlValue( space_h, spaces_temp );
  67.             }
  68.             else if ( ((item_hit == i_window) && (copy_mode_temp != c_window))
  69.                 || ((item_hit == i_everywhere) && (copy_mode_temp != c_all))
  70.                 || ((item_hit == i_selected_rect) && (copy_mode_temp != c_selected)) )
  71.             {
  72.                 if (item_hit == i_window)
  73.                     copy_mode_temp = c_window;
  74.                 else if (item_hit == i_everywhere)
  75.                     copy_mode_temp = c_all;
  76.                 else
  77.                     copy_mode_temp = c_selected;
  78.                 SetCtlValue( window_h, copy_mode_temp == c_window );
  79.                 SetCtlValue( everywhere_h, copy_mode_temp == c_all );
  80.                 SetCtlValue( selected_h, copy_mode_temp == c_selected );
  81.             }
  82.             else if (item_hit == i_fake_activate)
  83.             {
  84.                 fake_activate_temp = !fake_activate_temp;
  85.                 SetCtlValue( fake_activate_h, fake_activate_temp );
  86.             }
  87.         } while ( (item_hit != i_OK) && (item_hit != i_cancel) );
  88.         DisposDialog( dp );
  89.         
  90.         /* Any change? */
  91.         if ( (item_hit == i_OK) &&
  92.             ( (spaces_temp != spaces) || (copy_mode_temp != copy_mode) ||
  93.               (fake_activate_temp != fake_activate) ) )
  94.         {
  95.             copy_mode = copy_mode_temp;
  96.             spaces = spaces_temp;
  97.             fake_activate = fake_activate_temp;
  98.             Set_prefs();
  99.         }
  100.     }
  101.     SetPort( save_port );
  102.     UseResFile( save_resfile );
  103. }